package com.javafactroy.kunlong.codefactroy.service.domain.valueobj;

import com.javafactroy.kunlong.codefactroy.service.stringtemplate.StringTemplate;
import lombok.Data;

@Data
public class ColEqValueObj {

    StringTemplate stringTemplate ;

    String oprt = "=";
    String IF = "<if test=\"p.${propName} !=  null\">";
    String BODY = " and ${colName} = #{p.${propName}}";
    String ENDIF = "</if>";

    public ColEqValueObj() {
        stringTemplate = new StringTemplate();
        oprt = "=";
        IF = "\r\t<if test=\"p.${propName} !=  null\">";
        BODY = "\t\t and ${colName} = #{p.${propName}}";
        ENDIF = "\t\t</if>";

    }

    public ColEqValueObj putParam(String key, Object value) {
        stringTemplate.putParam(key, value);
        return this;
    }

    public String toCodeString() {
        StringBuffer sb = new StringBuffer(128);
        sb.append(IF).append("\r\n");
        sb.append(BODY).append("\r\n");
        sb.append(ENDIF).append("\r\n");
        return sb.toString();
    }
}
